<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_collect.php");                     // 当前页面的控制器 ?>



<body>





<!--顶部栏-->
<div id="topbar"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<? echo $now_extender ?>">

    <!--侧边栏-->
    <div id="sidebar"><?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/sidebar.php'; ?></div>


    <div id="content">
        <?php $page_title='订单统计';?>
        <?php include ROOT_PATH_.'/controlbase/module/mod-page-title.php'; ?>





<div class="detail-box  layui-form">

<div class="detail-boxes">




    <form action="detail-collect.php" >

        <div class="select-box">
            <div class="layui-form-item search-period">
                <label class="layui-form-label">时间段</label>

                <div class="layui-input-block">
                    <input type="text" name="greaterequal_ondate"
                           placeholder="请输入开始时间" autocomplete="off" class="layui-input laydate_date"
                           value="<?if($_REQUEST['greaterequal_ondate']){echo $_REQUEST['greaterequal_ondate'] ;} ?>" >
                    <span>-</span>
                    <input type="text" name="lessequal_ondate"
                           placeholder="请输入结束时间" autocomplete="off" class="layui-input laydate_date"
                           value="<?if($_REQUEST['lessequal_ondate']){echo $_REQUEST['lessequal_ondate'];} ?>"  >
                </div>
            </div>




            <input type="hidden" name="now_extender" value="<?echo $_REQUEST['now_extender']?>">

            <button id="search_button" class="layui-btn  layui-btn-sm" ><i class="layui-icon">&#xe615;</i> 查找</button>
            <a class="layui-btn white layui-btn-sm" href="detail-statistic.php?now_extender=<?echo $_REQUEST['now_extender']?>" ><i class="layui-icon">&#x1006;</i> 重置</a>
            <a class="layui-btn white layui-btn-sm" target="_blank"
               href="export-detail-collect.php?greaterequal_ondate=<?echo $_REQUEST['greaterequal_ondate']?>&lessequal_ondate=<?echo $_REQUEST['lessequal_ondate']?>&now_extender=<?echo $_REQUEST['now_extender']?>" >
                <i class="layui-icon">&#xe62d;</i> 导出配送汇总</a>

        </div>







        <br class="clearfloat"/>
    </form>


</div>
    <blockquote class="layui-elem-quote">
        <div>需要所有学校数据，请直接导出excel。由于所有数据均为实时计算，需要消耗一定时间。</div>
        <div>本表格用于配送，<a href="order-pepare-statistic.php?now_extender=order"  style="color:red;">盘点</a>仅需要产品数量的可以查看<a href="order-pepare-statistic.php?now_extender=order" style="color:red;">备货统计</a></div>
    </blockquote>



 <hr/>


<table class="layui-table">
    <thead>
    <tr>
        <th>学校</th>
        <th>数量</th>
        <th>明细</th>
        <th>日期</th>
    </tr>
    </thead>
    <tbody>
    <?foreach ($school_list as $k=>$v){?>
    <tr>
        <td><?echo $v['name']?></td>
 <?//print_r2($detail[$v['name']]);    ?>

        <td> <?
                $parameter['key']='status';//需要统计的键值
                $parameter['value']='正常';//需要统计
                echo $shcool_sum[]=count_sum_with_key_in_2d_array($detail[$v['name']],$parameter);
                ;?>
        </td>
        <td>
            <?
                $_product_name_list=transform_2darray_in_1darray_number_as_key($detail[$v['name']],'product_name');
                $_product_name_list=array_unique($_product_name_list);


                foreach ($_product_name_list as $k2=>$v2)
                {
                    $p['key']='product_name';//需要统计的键值
                    $p['value']=$v2;//需要统计
                    echo $v2.": ".count_sum_with_key_in_2d_array($detail[$v['name']],$p)."<br/>";
                }
            ?>
        </td>
        <td>
        <?echo $_REQUEST['greaterequal_ondate']?> 至
        <?echo $_REQUEST['lessequal_ondate']?>
        </td>

    </tr>
    <?}?>
    <tr>
        <td>合计</td>
        <td colspan="4">
            <?
//                $p['item']="order_id";
//                $p['table']=$table_prefix."order_info";
//                $p['condition']="startdate <=  '{$indate} 00:00:00'   and
//                              enddate >=  '{$indate} 00:00:00'  and
//                              add_date < '{$indate}  00:00:00' and
//                              (status !='已删除' or status is null) and
//                              pay_status = 1";
//
//                $result=count_number($p);
//               echo $result[0];

                echo $shcool_sum_total=array_sum($shcool_sum);
                ?>
        </td>
    </tr>
    </tbody>
</table>








</div>
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>


<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>



</body>



</html>
